<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>
  <body>
    <div><ul>
      <li><a class="active" href="/">Home</a></li>
      <li><a href="login">测试JWT</a</li>
      <li><a href="logout">退出登录</a></li>
      <li><a href="regist">立即注册</a></li>
    </ul>
  </div>
  <h1 onclick="mySubmit()">Test</h1>
  <p>Welcome to </p>
  </body>
  <script>
    const request = axios.create({
      baseURL: 'http://localhost:3000/test/', // 设置请求的baseURL
      withCredentials: true,
      timeout: 5000 // 设置请求超时时间
    })
    request.interceptors.request.use(
      (config) => {       
        let token = localStorage.getItem('token')
        if (token) {
          config.headers['Authorization'] = token
        }
        return config
      })
    function mySubmit(){ 
      var token = localStorage.getItem("token");
      request.get('verify').then((res)=>{
        console.log(res.data);        
		    alert('uid:'+res.data.uid);
      });
    }
 </script>
</html>
